package com.maoyanjava.controller;

import com.maoyanjava.pojo.Seat;
import com.maoyanjava.service.SeatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
public class SeatController {
    @Autowired
    private SeatService Ss;
    @GetMapping("/seat")
    public List<Seat> getAllByPid(HttpServletRequest request, HttpServletResponse response){
        String pid = request.getParameter("pid");
        return Ss.getAllByPid(Integer.parseInt(pid));
    }
    //修改座位 1
    @GetMapping("/updateseat1/{no}/{pid}")
    public int updateseat1(@PathVariable("no") Integer no, @PathVariable("pid") Integer pid){
        int i = Ss.updateSeat1(no,pid);
        return i;
    }
    //修改座位 0
    @GetMapping("/updateseat0/{no}/{pid}")
    public int updateseat0(@PathVariable("no") Integer no,@PathVariable("pid") Integer pid){
        int i = Ss.updateSeat0(no,pid);
        return i;
    }
    @GetMapping("/updateseat2")
    public int updateseat2(){
        int i = Ss.updateSeat2();
        return i;
    }
}
